package com.mfl.mapper;

import com.github.pagehelper.Page;
import com.mfl.pojo.dto.CollectPageQueryDTO;
import com.mfl.pojo.entity.Collect;
import com.mfl.pojo.vo.CollectPageQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CollectMapper {
    /**
     * 添加收藏
     * @param collect
     */
    void add(Collect collect);

    /**
     * 根据用户id,类型id和类型查询收藏
     * @param currentId
     * @param id
     * @param book
     * @return
     */
    @Select("select * from collect where user_id = #{currentId} and type_id = #{typeId} and type = #{type}")
    Collect selectByUserIdAndBookId(Integer currentId, int typeId, String type);

    /**
     * 根据id和类型查询收藏数量
     * @param id
     * @param book
     * @return
     */
    @Select("select count(*) from collect where type_id = #{typeId} and type = #{type}")
    int selectCount(int typeId, String type);

    /**
     * 删除收藏
     * @param collect
     */
    void delCollect(Collect collect);

    /**
     * 分页查询收藏
     * @param collectPageQueryDTO
     * @return
     */
    Page<CollectPageQueryVO> pageQuery(CollectPageQueryDTO collectPageQueryDTO);
}
